<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/9/21
  Time: 15:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.List"%>
<%@page import="java.util.Map"%>

<html>
<head>
    <title>图书借阅</title>
    <link rel="stylesheet" href="/css/base.css">
    <link rel="stylesheet" href="/css/common.css">
    <link rel="stylesheet" href="/css/readeradmin.css">
    <link rel="stylesheet" href="/css/booksearch.css">
    <link rel="stylesheet" href="/css/index.css">
    <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
    <style type="text/css">
        .fengye{
            border: 1px solid;
            display: inline;
            padding: 8px 16px;
        }

        span{
            color: aliceblue;
        }
        table{

            width: 980px;
        }


        td{

            overflow: hidden;

        }

        #fff{
            float: left;
            margin-left: 50px;
            width:693px;
            height: 44px;
            border: 1px solid black;
            position: relative;
        }

        #sss {
            float: left;
            height: 41px;
            width: 100px;
            text-align: center;
        }

        #ttt {
            float: left;
            width: 510px;
            height: 41px;
            padding-left: 10px;
            line-height: 41px;
        }

        #iii {
            /* float: right; */
            position: absolute;
            top: 0;
            left: 611px;
            width: 80px;
            height: 41px;
            background-color: #2d241d;
            font-size: 16px;
            color: #fff;
        }
        .tupian img {
            float: right;
            width: 980px;
            height: 465px;
        }

        .minyan {
            float: left;
            width: 100%;
            height: 163px;
            margin-top: 12px;
            background-color: green;
            text-align: center;
            font-size: 20px;
            font-weight: bold;
            line-height: 163px;
            color: #fff;
            background: rgba(0, 0, 0, 0.7);
        }

    /*    <title>借阅图书表</title>*/
    /*<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>*/
    /*<style type="text/css">*/
    /*    li{*/
    /*        border: 1px solid;*/
    /*        display: inline;*/
    /*        padding: 8px 16px;*/
    /*    }*/
    </style>
</head>
<body>
<%
    String contextPath = request.getSession().getServletContext().getContextPath();
%>
<section class="shortcut">
    <div class="w">
        <div class="fl">
            <ul>
                <li>图书管理系统！&nbsp;</li>
                <li>
                    <a href="index.html">请登录</a> &nbsp;
                    <a href="#" class="style-red">借阅图书</a>
                </li>
            </ul>
        </div>
        <div class="fr">
            <ul>
                <li class="arrow-icon">我的消息</li>
                <li>|</li>
                <li class="arrow-icon"> <a href="<%=contextPath%>/admin/">退出</a></li>
            </ul>
        </div>
    </div>
</section>
<!-- 头部模块 -->
<header class="header w">
    <!-- logo -->
    <div class="logo">
        <h1>
            <a href="index.html" title="图书管理系统">人类进步的阶梯</a>
        </h1>
    </div>



</header>
<nav class="nav">
    <div class="w">
        <div class="dropdown">
            <div class="dt"> <a href="aindex.html">首页</a> </div>
            <div class="dd">
                <ul>
                    <li><a href="<%=contextPath%>/admin/User/">用户管理</a> </li>
                    <li><a href="<%=contextPath%>/admin/book/">图书管理</a> </li>
                    <li><a href="<%=contextPath%>/admin/borrow/">图书借阅管理</a> </li>

                    <li><a href="<%=contextPath%>/admin/inform/all/">通知</a></li>
                    <li><a href="<%=contextPath%>/admin/adminPCenter/">个人中心</a> </li>

                </ul>
            </div>
        </div>
        <form  id="fff"   action="<%=contextPath%>/admin/borrow/select" method="post">
            <select id="sss"    name="select">
                <option value="zhanghao">账号</option>
                <option value="username">用户名</option>
            </select>
            <input  id="ttt"   type="text" name="text" />
            <input id="iii"    type="submit" value="搜索"/><br><br>
        </form>


    </div>
</nav>
<%--    <h1>借阅图书表</h1>--%>
<%--    <a href="<%=contextPath%>/admin/">退出</a>--%>
<%--    <form action="<%=contextPath%>/admin/borrow/select" method="post" onsubmit="return testEmpty()">--%>
<%--        <select name="select">--%>
<%--            <option value="zhanghao">账号</option>--%>
<%--            <option value="username">用户名</option>--%>
<%--        </select>--%>
<%--        <input type="text" name="text" id="text"/>--%>
<%--        <input type="submit" value="搜索"/><br><br>--%>
<%--    </form>--%>

<%--    <table border="1px solid">--%>
<%--        <th>借书编号</th>--%>
<%--        <th>图书编号</th>--%>
<%--        <th>用户名</th>--%>
<%--        <th>用户账号</th>--%>
<%--        <th>书名</th>--%>
<%--        <th>借阅时间</th>--%>
<%--        <th>应当归还时间</th>--%>
<%--        <th>实际归还时间</th>--%>
<%--        <th>超时归还时间</th>--%>
<%--        <th>续借时间</th>--%>
<%--        <th>是否归还</th>--%>
<div class="w">
    <div class="main">
        <table  id="mainTable" align="center " border="1 " cellpadding="1px " cellspacing="2px " width="980px "  ;>
            <thead class="biaoge ">
            <tr>
                <th>借书编号</th>
                <th>图书编号</th>
                <th>用户名</th>
                <th>用户账号</th>
                <th>书名</th>
                <th>借阅时间</th>
                <th>应当归还时间</th>
                <th>实际归还时间</th>
                <th>超时归还时间</th>
                <th>续借时间</th>
                <th>是否归还</th>
                <th>操作</th>
            </tr>
            </thead>
        <%
            List<Map<String,Object>> borrows = (List<Map<String, Object>>) request.getAttribute("borrows");
            if(borrows!=null){
            for(int i = 0;i < borrows.size();i++){
                Map<String,Object> borrow = borrows.get(i);

        %>
        <tr>
            <td><%=borrow.get("borrid")%></td>
            <td><%=borrow.get("id")%></td>
            <td><%=borrow.get("userName")%></td>
            <td><%=borrow.get("zhanghao")%></td>
            <td><%=borrow.get("bName")%></td>
            <td><%=borrow.get("borrowTime")%></td>
            <td><%=borrow.get("returnTime")%></td>
            <td><%=borrow.get("reallyTime")%></td>
            <td><%=borrow.get("overTime")%></td>
            <td><%=borrow.get("xujieTime")%></td>
            <td><%=borrow.get("isreturn")%></td>
            <td class="overRemind">超时归还提醒</td>
        </tr>
        <%}%>
        <%}%>
    </table>
    <br><br>
        <div>
            <li class="fengye"><a onclick="deleteYeshu()"><<</a></li>
            <li class="fengye">第<label name="yeshu" id="yeshu">${yeshu}</label>页</li>
            <li class="fengye"><a onclick="addYeshu()">>></a></li>
        </div>

<%--</body>--%>
<script type="text/javascript">
    function addYeshu(){
        var yeshu1 = document.getElementById("yeshu");
        window.location.href="<%=contextPath%>/admin/borrow/search/add?yeshu="+yeshu1.innerText;
    }
    function deleteYeshu(){
        var yeshu1 = document.getElementById("yeshu");
        window.location.href="<%=contextPath%>/admin/borrow/search/delete?yeshu="+yeshu1.innerText;
    }

    function testEmpty(){
        var test = document.getElementById("text").value;
        if(test.length > 0){
            return true;
        }else{
            alert("空")
            return false;
        }
    }

    $(function (){
        $(".overRemind").click(function () {
            var j = this.parentNode.children[0].innerHTML;
            var isreturn = this.parentNode.children[10].innerHTML;

            if(isreturn=="true"){
                alert("用户已归还");
            }else {
                $.ajax({
                    type: "post",
                    url: "<%=contextPath%>/admin/inform/remind",
                    data: {
                        "borrid": j,
                    },
                    success: function (msg) {
                        if (msg == true) {
                            alert("超时提醒成功！")
                        } else {
                            alert("用户未超时，提醒失败")
                        }
                    }
                })
            }
        })})
</script>
    </div>
</div>
<div class="w ">
    <div class="minyan">

        好好建设图书馆，全心全意为读者服务！

    </div>
</body>
</html>
